<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;


class CreateDealsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('deals', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('user_id')->nullable()->comment('卖出用户id=user.id');
            $table->decimal('price','16','2')->comment('单价');
            $table->integer('total_amount')->default('0')->comment('总量');
            $table->integer('rest_amount')->default('0')->comment('剩余数量');
            $table->decimal('total_price',16,2)->default('0')->comment('总计收入');
            $table->tinyInteger('status')->default('1')->comment('状态(1进行中/2已取消/3已完成)');
            $table->tinyInteger('is_deleted')->default('0')->comment('是否删除');
            $table->timestamps();
        });
        DB::statement("ALTER TABLE `deals` comment '卖出记录表';");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('deals');
    }
}
